//
//  XYComposeButton.swift
//  SinaWB_XY
//
//  Created by 小熊猫 on 15/10/21.
//  Copyright © 2015年 小熊猫. All rights reserved.
//

import UIKit

//按钮的宽高
let BUTTON_W:CGFloat = 80
let BUTTON_H:CGFloat = 110

class XYComposeButton: UIButton {
    
    override var highlighted:Bool{
        set{
            
        }
        get{
            return false
        }
    }
    

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        size = CGSizeMake(BUTTON_W, BUTTON_H)
        
        //文字居中
        self.titleLabel?.textAlignment = NSTextAlignment.Center
        //文字颜色
        setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        //文字大小
        titleLabel?.font = UIFont.systemFontOfSize(14)
        
        
        //图片的显示方式
        imageView?.contentMode = UIViewContentMode.Center
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        //先调整图片
        imageView?.x = 0
        imageView?.y = 0
        imageView?.width = BUTTON_W
        imageView?.height = BUTTON_W
        
        //调整label
        titleLabel?.x = 0
        titleLabel?.y = BUTTON_W
        titleLabel?.width = BUTTON_W
        titleLabel?.height = BUTTON_H - BUTTON_W
        
    }


}
